package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.busiexception.BusiException;
import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(BusiException.class)
    public Result handleBusiException(BusiException e) {
        e.printStackTrace();
        System.out.println(e.getMessage() + e.getCause()+"---------------------------------------");
        return Result.fail("业务异常，未找到房间id，请联系管理员" + e.getMessage() + e.getCause(), null, 500);
    }

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        e.printStackTrace();
        System.out.println(e.getMessage() + e.getCause()+"---------------------------------------");
        return Result.fail("系统异常，请联系管理员" + e.getMessage() + e.getCause(), null, 500);
    }
}
